<?php

namespace config\Test;

use think\console\Command;
use think\console\Input;
use think\console\Output;

class Test extends Command
{
    protected function configure()
    {
        $this->setName('test')->setDescription('Here is the remark ');
    }

    protected function execute(Input $input, Output $output)
    {
        $output->writeln("TestCommand:");
        $this->runs();
    }

    public function runs()
    {
        $pid = pcntl_fork(); //fork 一个子进程
        if ($pid > 0) {
            echo "父进程 PID：" . posix_getpid() . PHP_EOL;
        } else if ($pid == 0) {
            while (true) {
                usleep(10);
                echo "MyPid:" . getmypid() . PHP_EOL;
            }
        } else {
            echo "fork 进程错误" . PHP_EOL;
        }
    }
}